
#ifndef _LBW_OP_QUERY_H
#define _LBW_OP_QUERY_H


#include <Lcode/l_code.h>



#define INT_2EXP(i)             (LLCONST(0x01) << (i))

#define UIMM_4(a)      ((((a) >= 0) && ((a) <= INT_2EXP(4)))?1:0)

#define SIMM_6(a)     ((((a) > -INT_2EXP(5))&&((a) < INT_2EXP(5) ))?1:0)

/* 6 bit unsigned immediate field */
#define UIMM_6(a)      ((((a) >= 0) && ((a) <= INT_2EXP(6)))?1:0)

/* 8 bit signed immediate field: 1bit sign, 7 bit number */
#define SIMM_8(a)     ((((a) > -INT_2EXP(7))&&((a) < INT_2EXP(7) ))?1:0)

#define UIMM_8(a)      ((((a) >= 0) && ((a) <= INT_2EXP(8)))?1:0)

/* 9 bit signed immediate field: 1bit sign, 7 bit number */
#define SIMM_9(a)     ((((a) > -INT_2EXP(8))&&((a) < INT_2EXP(8) ))?1:0)

#define UIMM_12(a)      ((((a) >= 0) && ((a) <= INT_2EXP(12)))?1:0)
/* 12 bit signed immediate field: */
#define SIMM_12(a)     ((((a) > -INT_2EXP(11))&&((a) < INT_2EXP(11)))?1:0)

/* 16 bit signed immediate field: */
#define SIMM_16(a)     ((((a) > -INT_2EXP(15))&&((a) < INT_2EXP(15)))?1:0) 
/*16 bit unsigned immediate field:*/
 #define UIMM_16(a)      ((((a) >= 0) && ((a) <= INT_2EXP(16)))?1:0)


/* 22 bit signed immediate field: */
#define SIMM_32(a)     ((((a) > -INT_2EXP(31))&&((a) < INT_2EXP(31)))?1:0)
#define UIMM_32(a)      ((((a) >= 0) && ((a) <= INT_2EXP(32)))?1:0)

#define LT_is_R0_operand(op)        ((op) && \
                                     (op)->type == L_OPERAND_MACRO && \
                                     (op)->value.mac == TAHOE_MAC_ZERO)
#endif
